package itheima.com.Day13.Test1;

public class Cooker extends Thread {
    @Override
    public void run() {
        //因为
        while (true){
            synchronized (Desk.lock){
                if(Desk.count == 0){
                    break;
                }else{
                    if(!Desk.flag){
                        //没有汉堡包就做
                        System.out.println("厨师在做汉堡包");
                        //改变现有状态，已经做好啦
                        Desk.flag=true;
                        //唤醒全部等待的消费者线程
                        Desk.lock.notifyAll();
                    }else {
                        //还有汉堡包就等待
                        try {
                            Desk.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
